package day01;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class sleep {
    public static void main(String[] args) throws InterruptedException {

        Thread t1 = new Thread("t1") {
            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        };

        t1.start();
        // 一开始是 main线程先执行的  此时t1线程还没处于睡眠状态 所以是runnable就绪状态
        log.debug("t1的state: {}", t1.getState());
        // 主线程睡眠,这时候t1线程进入睡眠了,才打印出timed_waiting阻塞状态
        Thread.sleep(500);
        log.debug("t1的state: {}", t1.getState());




    }
}
